using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Collections.Generic;
using System.Collections;

using J2ME.RMS;
using Nextel.Utils;

namespace Java.binario.bean
{

    public class RutaPorCodigoBean : Persistente, IComparable<RutaPorCodigoBean>
    {
        public int idRecordRuta;
        public short posRecordRuta;
        public String campoBuscar;

        public override void persistir(DataOutputStream dataOutput, List<Persistente> list)
        {
            dataOutput.writeInt(list.Count);
            for (int i = 0; i < list.Count; i++)
            {
                RutaPorCodigoBean rutaCodigo = (RutaPorCodigoBean)list[i];
                dataOutput.writeInt(rutaCodigo.idRecordRuta);
                dataOutput.writeShort(rutaCodigo.posRecordRuta);
                dataOutput.writeString(StringUtils.stringNullToBlank(rutaCodigo.campoBuscar));
            }
        }

        public int CompareTo(RutaPorCodigoBean bean)
        {
            try
            {
                int x = this.campoBuscar.Length;
                int y = bean.campoBuscar.Length;

                if (x == y)
                {
                    return campoBuscar.CompareTo(bean.campoBuscar);
           
                }
                else if (x > y)
                {
                    return 1;
                }
                else
                {
                    return -1;
                }
            }

            catch (Exception ex)
            {
                return -1;
            }

        }



    }
    
}
